package com.yx.common.core.exception.custom;

public class MyException extends RuntimeException {
	private static final long serialVersionUID = 1L;


    private IMyException iMyException;

    private int code;

    private String msg;

    /**
     * 错误编码
     */
    private int errorCode=500;

    public MyException(IMyException iMyException) {
        this.setiMyException(iMyException);
        this.setCode(iMyException.getCode());
        this.setMsg(iMyException.getMsg());
    }

    /**
     * 构造一个基本异常.
     *
     * @param message
     *            信息描述
     */
    /*public MyException(String message)
    {
        super(message);
    }*/
    public MyException(String message)
    {
        this.setMsg(message);
    }

    /**
     * 构造一个基本异常.
     *
     * @param errorCode
     *            错误编码
     * @param message
     *            信息描述
     */
    /*public MyException(int errorCode, String message)
    {
        super(message);
        this.setCode(errorCode);
    }*/
    public MyException(int errorCode, String message)
    {
        this.setMsg(message);
        this.setCode(errorCode);
    }
    /**
     * 构造一个基本异常.
     *
     * @param errorCode
     *            错误编码
     * @param message
     *            信息描述
     */
    public MyException(int errorCode, String message, Throwable cause)
    {
        super(message, cause);
        this.setErrorCode(errorCode);
    }

    /**
     * 构造一个基本异常.
     *
     * @param message
     *            信息描述
     * @param cause
     *            根异常类（可以存入任何异常）
     */
    public MyException(String message, Throwable cause)
    {
        super(message, cause);
    }
    
    public int getErrorCode()
    {
        return errorCode;
    }

    public void setErrorCode(int errorCode)
    {
        this.errorCode = errorCode;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public IMyException getiMyException() {
        return iMyException;
    }

    public void setiMyException(IMyException iMyException) {
        this.iMyException = iMyException;
    }
}
